﻿using Abp.EntityFrameworkCore;
using Abp.EntityFrameworkCore.Configuration;
using Abp.Modules;
using Microsoft.EntityFrameworkCore;
using Admin.EntityFrameworkCore;

namespace Admin
{
    [DependsOn(typeof(AbpEntityFrameworkCoreModule))]
    public class AdminEntityFrameworkCoreModule : AbpModule
    {
        public override void PreInitialize()
        {
            Configuration.Modules.AbpEfCore().AddDbContext<AdminDbContext>(options =>
            {
                if (options.ExistingConnection == null)
                    options.DbContextOptions.UseSqlite(options.ConnectionString);
                else
                    options.DbContextOptions.UseSqlite(options.ExistingConnection);
            });
        }

        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(typeof(AdminEntityFrameworkCoreModule).Assembly);
        }
    }
}